  
global data /bplimext/projects/p064_MathildeMunoz/initial_dataset
global outputs /bplimext/projects/p064_MathildeMunoz/work_area

************************************
* Replication for Figure 10
***************************************

*Starts from panel dataset created in dofile creating Fig8-9

use "$outputs/ES/paneldata_ES.dta", clear
xtset tina ano
drop if cae3==31091
g logE001=log(E001)
g logemp=log(E001)
g loghours=log(E012)
g logwage=log(wage_cap)
g logwagebill=log(D029)
g logca=log(D001)
g logtemp=log(E010)
g logEBT=log(D086)
g logparttime=log(E007)
g loginternal=log(1+D001-MG005)
g logassets=log(B001)
g logservices=log(MG011)
g logturnoverinternal=log(MG001+MG002)
g logestabfor=log(numestabest)
g logtangible=log(B012)
g logcash=log(B049)
g loghourstemp=log(E018)
g loghourspart=log(E017)
g logssc=log(DL013)
g logtax=log(D060)
g logdebt=log(B081)
*drop if cae3==31091

*drop firms that export to other EU market (no posting)
g export_other=0
replace export_other=1 if MG008>0
egen panel_export_other=sum(export_other), by(tina)
g alt_treat=0
replace alt_treat=1 if panel_export_other>=1
drop if alt_treat==1
drop cluster
egen cluster1=group(ano distrito)
egen cluster2=group(cae3 ano)
egen cluster3=group(cae3 dimcomissao)
*binning coefficients
g coeff_up=0
replace coeff_up=1 if treated==1 & time>6
g coeff_bottom=0
replace coeff_bottom=1 if treated==1 & time<-4

label var coeff_up ">6"
*drop if ano<2008
drop if event_d<2010 & treated==1
drop if event_d>2015 & treated==1

g coeff_up2=0
replace coeff_up2=1 if time>4 & treated==1
label var coeff_up2 ">4"

global depvar logassets E001 logemp loghours logwage logwagebill logca logEBT logparttime loginternal
label var coeff_bottom "-4<"

   egen median=median(E001), by(tina)
   drop if median<3
   drop if median==.
   
   g export_servicedum=export_service_EU 
   replace export_servicedum=0 if ano==event_d
   
   g post=0
   replace post=1 if time>-1 & treated==1
   sort tina ano 
   order tina treated ano event_d export_service_EU post 
   
   



   foreach y in logwage logca logassets loghours logemp logcash logtangible logEBT logdebt loghourstemp loghourspart logssc logtax logwagebill{
   reghdfe `y' i.post , absorb(i.tina i.cae3 i.ano i.distrito i.ano##i.distrito##i.cae3) cluster(cluster1)
   outreg2 using "$outputs/ES/Baseline_Export5/Estimates/`y'_full_c1_average.txt",replace
   reghdfe `y' i.post if treated==1 , absorb(i.tina i.cae3 i.ano i.distrito i.ano##i.distrito##i.cae3) cluster(cluster1)
   outreg2 using "$outputs/ES/Baseline_Export5/Estimates/`y'_ot_c1_average.txt",replace

   }
   
  order tina treated ano event_d export_service_EU post cum
  egen min_year=min(ano), by(tina)
  egen max_year=max(ano), by(tina)
  order tina treated ano event_d export_service_EU post cum min_year max_year
  
  egen panel_treatment=sum(export_service_EU), by(tina)
  g fulltakers=0
  replace fulltakers=1 if panel_treatment==max_year-event_d+1
  
  g twoyears=0
  replace twoyears=1 if cum==2 & time==1 & panel_treatment==2
  egen twoyearsd=max(twoyears), by(tina)
  
  g threeyears=0
  replace threeyears=1 if cum==3 & time==2 & panel_treatment==3
  egen threeyearsd=max(threeyears), by(tina)
  
  g fouryears=0
  replace fouryears=1 if cum==4 & time==3 & panel_treatment==4
  egen fouryearsd=max(fouryears), by(tina)
  
  
  
  g indicno1=0
  replace indicno1=1 if treated==1 & fulltakers==0
  
  g indicno2=0
  replace indicno2=1 if treated==1 & twoyearsd==0
  
  g indicno3=0
  replace indicno3=1 if treated==1 & threeyearsd==0
  
  g indicno4=0
  replace indicno4=1 if treated==1 & fouryearsd==0
  
  
  g observationpost=max_year-event_d+1
  replace observationpost=0 if treated==0
  
  g alertobs2=0
  replace alertobs2=1 if observationpost==2 & treated==1
  
  g alertobs3=0
  replace alertobs3=1 if observationpost==3 & treated==1
  
  
  
  foreach x in logwage logEBT logca logwagebill loghours logassets loginternal{
  reghdfe `x' coeff_bottom coeff_7-coeff_9 zero coeff_11-coeff_15 coeff_up2, absorb( i.tina i.cae3 i.ano i.distrito i.ano##i.distrito##i.cae3) cluster(cluster1)
  est save "$outputs/ES/Baseline_Export5/Hetero1/Estimates/`x'_baseline_c1.ster", replace
  reghdfe `x' coeff_bottom coeff_7-coeff_9 zero coeff_11-coeff_15 coeff_up2 if indicno1!=1, absorb( i.tina i.cae3 i.ano i.distrito i.ano##i.distrito##i.cae3) cluster(cluster1)
  est save "$outputs/ES/Baseline_Export5/Hetero1/Estimates/`x'_fulltakers_c1.ster", replace
  reghdfe `x' coeff_bottom coeff_7-coeff_9 zero coeff_11-coeff_15 coeff_up2 if indicno2!=1 & alertobs2!=1, absorb( i.tina i.cae3 i.ano i.distrito i.ano##i.distrito##i.cae3) cluster(cluster1)
  est save "$outputs/ES/Baseline_Export5/Hetero1/Estimates/`x'_2yearstakers_c1.ster", replace
  reghdfe `x' coeff_bottom coeff_7-coeff_9 zero coeff_11-coeff_15 coeff_up2 if indicno3!=1 & event_d!=2015 & alertobs3!=1, absorb( i.tina i.cae3 i.ano i.distrito i.ano##i.distrito##i.cae3) cluster(cluster1)
  est save "$outputs/ES/Baseline_Export5/Hetero1/Estimates/`x'_3yearstakers_c1.ster", replace
  }
  
   foreach x in logcash logtax logemp{
  reghdfe `x' coeff_bottom coeff_7-coeff_9 zero coeff_11-coeff_15 coeff_up2, absorb( i.tina i.cae3 i.ano i.distrito i.ano##i.distrito##i.cae3) cluster(cluster1)
  est save "$outputs/ES/Baseline_Export5/Hetero1/Estimates/`x'_baseline_c1.ster", replace
  reghdfe `x' coeff_bottom coeff_7-coeff_9 zero coeff_11-coeff_15 coeff_up2 if indicno1!=1, absorb( i.tina i.cae3 i.ano i.distrito i.ano##i.distrito##i.cae3) cluster(cluster1)
  est save "$outputs/ES/Baseline_Export5/Hetero1/Estimates/`x'_fulltakers_c1.ster", replace
  reghdfe `x' coeff_bottom coeff_7-coeff_9 zero coeff_11-coeff_15 coeff_up2 if indicno2!=1 & alertobs2!=1, absorb( i.tina i.cae3 i.ano i.distrito i.ano##i.distrito##i.cae3) cluster(cluster1)
  est save "$outputs/ES/Baseline_Export5/Hetero1/Estimates/`x'_2yearstakers_c1.ster", replace
  reghdfe `x' coeff_bottom coeff_7-coeff_9 zero coeff_11-coeff_15 coeff_up2 if indicno3!=1 & event_d!=2015 & alertobs3!=1, absorb( i.tina i.cae3 i.ano i.distrito i.ano##i.distrito##i.cae3) cluster(cluster1)
  est save "$outputs/ES/Baseline_Export5/Hetero1/Estimates/`x'_3yearstakers_c1.ster", replace
  }
  
  
  foreach x in logwage logEBT logca logwagebill loghours logassets logemp{
  reghdfe `x' coeff_bottom coeff_7-coeff_9 zero coeff_11-coeff_15 coeff_up2 if indicno1!=1, absorb( i.tina i.cae3 i.ano i.distrito i.ano##i.distrito##i.cae3) cluster(cluster1)
coefplot, keep( coeff_7 coeff_8 coeff_9 zero coeff_11 coeff_12 coeff_13 coeff_14 coeff_15  ) omit ///
vertical  graphregion(fcolor(white) lcolor(white)) recast(connected) ciopts(recast(rcap) lwidth(medthick)) yline(0, lpattern(dash) lcolor(gs10)) ylabel(-.2 (.2) .6) ///
xline(4.5, lcolor(red)) scale(1.2)
   graph export "$outputs/ES/Baseline_Export5/Figures/`x'_full_control.png", replace

  reghdfe `x' coeff_bottom coeff_7-coeff_9 zero coeff_11-coeff_15 coeff_up2 if indicno1!=1 & treated==1, absorb( i.tina i.cae3 i.ano i.distrito i.ano##i.distrito##i.cae3) cluster(cluster1)
  coefplot, keep( coeff_7 coeff_8 coeff_9 zero coeff_11 coeff_12 coeff_13 coeff_14 coeff_15  ) omit ///
vertical  graphregion(fcolor(white) lcolor(white)) recast(connected) ciopts(recast(rcap) lwidth(medthick)) yline(0, lpattern(dash) lcolor(gs10)) ylabel(-.2 (.2) .6) ///
xline(4.5, lcolor(red)) scale(1.2)
  
   graph export "$outputs/ES/Baseline_Export5/Figures/`x'_full_ot.png", replace

  
  
  }
  
  
  *************COMBINE ALL ESTIMATES TO CREATE FIG 10 for each outcome variable***************
  
  
  clear all
  foreach z in logwage logEBT logemp logwagebill logca logassets logcash loghours {
  foreach  x in baseline fulltakers 2yearstakers 3yearstakers{
  clear all
  est use "$outputs/ES/Baseline_Export5/Hetero1/Estimates/`z'_`x'_c1.ster"
  set obs 16
  g time=_n
  g beta`x'=0
  g se`x'=0
  forval y=7/9{
  replace beta`x'=_b[coeff_`y'] if time==`y'
  replace se`x'=_se[coeff_`y'] if time==`y'

  }
  
  forval y=11/15{
  replace beta`x'=_b[coeff_`y'] if time==`y'
  replace se`x'=_se[coeff_`y'] if time==`y'
  }
  
  replace beta`x'=_b[coeff_bottom] if time==6 
  replace se`x'=_se[coeff_bottom] if time==6 
  
  replace beta`x'=_b[coeff_up2] if time==16
  replace se`x'=_se[coeff_up2] if time==16 

  g timed=time-11
  
  g ub`x'=beta+1.96*se
  g lb`x'=beta-1.96*se
  save "$outputs/ES/Baseline_Export5/Hetero1/Estimates/`z'_`x'_c1.dta", replace
  
  }
  }
  
   use "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logwage_baseline_c1.dta", clear
   foreach  x in baseline fulltakers 2yearstakers 3yearstakers{
   merge 1:1 timed using "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logwage_`x'_c1.dta"
   drop _m
  }
  keep if timed>-6
  
  
  twoway (connected beta2yearstakers timed if timed>-5 & timed<5, mcolor(cranberry) lcolor(cranberry) ) ///
  (rcap ub2yearstakers lb2yearstakers timed if timed>-5 & timed<5, lcolor(cranberry) lwidth(medthick)) ///
   (connected beta3yearstakers timed if timed>-5 & timed<5, mcolor(black) lcolor(black) ) ///
  (rcap ub3yearstakers lb3yearstakers timed if timed>-5 & timed<5, lcolor(black) lpattern(dash) lwidth(medthick)) ///
   (connected betafulltakers timed if timed>-5 & timed<5, mcolor(blue) lcolor(blue)) ///
  (rcap ubfulltakers lbfulltakers timed if timed>-5 & timed<5, lcolor(blue) lpattern(dash) lwidth(medthick)) ///
  , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.2) .6) ///
  xlabel(-4 (1) 4) xtitle("") ///
  legend(label(1 "2 years Posting") label(3 "3 years Posting") label(5 "Full period Posting") cols(1) ring(0) pos(11) order(5 3 1)) ///
  xline(0.5, lcolor(red))
  graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logwage_combined.png", replace
  
    twoway ///
   (connected beta3yearstakers timed if timed>-5 & timed<5, mcolor(black) lcolor(black) ) ///
  (rcap ub3yearstakers lb3yearstakers timed if timed>-5 & timed<5, lcolor(black) lpattern(dash) lwidth(medthick)) ///
    , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.2) .6) ///
  xlabel(-4 (1) 4) xtitle("") legend(label(1 "3 years Posting") ring(0) pos(11) cols(1) order(1)) ///
  xline(-0.5, lcolor(red)) xline(2.5, lcolor(red))
   graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logwage_3y.png", replace

      twoway ///
   (connected beta2yearstakers timed if timed>-5 & timed<5, mcolor(cranberry) lcolor(cranberry) ) ///
  (rcap ub2yearstakers lb2yearstakers timed if timed>-5 & timed<5, lcolor(cranberry) lwidth(medthick)) ///
    , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.2) .6) ///
  xlabel(-4 (1) 4) xtitle("") legend(label(1 "2 years Posting") ring(0) pos(11) cols(1) order(1)) ///
    xline(-0.5, lcolor(red)) xline(1.5, lcolor(red))
   graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logwage_2y.png", replace
  
     twoway ///
   (connected betafulltakers timed if timed>-5 & timed<5, mcolor(blue) lcolor(blue) ) ///
  (rcap ubfulltakers lbfulltakers timed if timed>-5 & timed<5, lcolor(blue) lpattern(dash) lwidth(medthick)) ///
    , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.2) .6) ///
  xlabel(-4 (1) 4) xtitle("") legend(label(1 "Full Period Posting") ring(0) pos(11) cols(1) order(1)) ///
  xline(-0.5, lcolor(red))
   graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logwage_full.png", replace
   
   use "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logwage_baseline_c1.dta", clear
   foreach  x in baseline fulltakers {
   merge 1:1 timed using "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logwage_`x'_c1.dta"
   drop _m
  }
  rename betafulltakers betafullwage
  rename lbfulltakers lbfullwage
  rename ubfulltakers ubfullwage
  
  foreach  x in baseline fulltakers {
   merge 1:1 timed using "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logEBT_`x'_c1.dta"
   drop _m
  }
  
  keep if timed>-6
   
   twoway ///
   (connected betafulltakers timed if timed>-5 & timed<5, mcolor(blue) lcolor(blue) ) ///
  (rcap ubfulltakers lbfulltakers timed if timed>-5 & timed<5, lcolor(blue)) ///
  (connected betafullwage timed if timed>-5 & timed<5, mcolor(cranberry) lcolor(cranberry) ) ///
  (rcap ubfullwage lbfullwage timed if timed>-5 & timed<5, lcolor(cranberry)),  ///
   graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.2) .6) ///
  xlabel(-4 (1) 4) xtitle("") legend(label(1 "Profits") label(3 "Wages") ring(0) pos(11) cols(1) order(1 3)) ///
  xline(-0.5, lcolor(red))
   graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logEBTvswage_combined.png", replace

   ***********************************
  
   use "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logEBT_baseline_c1.dta", clear
   foreach  x in baseline fulltakers 2yearstakers 3yearstakers{
   merge 1:1 timed using "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logEBT_`x'_c1.dta"
   drop _m
  }
  keep if timed>-6
  
  
  twoway (connected beta2yearstakers timed if timed>-5 & timed<5, mcolor(cranberry) lcolor(cranberry) ) ///
  (rcap ub2yearstakers lb2yearstakers timed if timed>-5 & timed<5, lcolor(cranberry) lwidth(medthick)) ///
   (connected beta3yearstakers timed if timed>-5 & timed<5, mcolor(black) lcolor(black) ) ///
  (rcap ub3yearstakers lb3yearstakers timed if timed>-5 & timed<5, lcolor(black) lpattern(dash) lwidth(medthick)) ///
   (connected betafulltakers timed if timed>-5 & timed<5, mcolor(blue) lcolor(blue)) ///
  (rcap ubfulltakers lbfulltakers timed if timed>-5 & timed<5, lcolor(blue) lpattern(dash) lwidth(medthick)) ///
  , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.8 (.4) .8) ///
  xlabel(-4 (1) 4) xtitle("") ///
  legend(label(1 "2 years Posting") label(3 "3 years Posting") label(5 "Full period Posting") cols(1) ring(0) pos(11) order(5 3 1)) ///
  xline(-0.5, lcolor(red))
  graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logEBT_combined.png", replace
  
    twoway ///
   (connected beta3yearstakers timed if timed>-5 & timed<5, mcolor(black) lcolor(black) ) ///
  (rcap ub3yearstakers lb3yearstakers timed if timed>-5 & timed<5, lcolor(black) lpattern(dash) lwidth(medthick)) ///
    , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.8 (.4) .8) ///
  xlabel(-4 (1) 4) xtitle("") legend(label(1 "3 years Posting") ring(0) pos(11) cols(1) order(1)) ///
  xline(-0.5, lcolor(red)) xline(2.5, lcolor(red))
   graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logEBT_3y.png", replace

      twoway ///
   (connected beta2yearstakers timed if timed>-5 & timed<5, mcolor(cranberry) lcolor(cranberry) ) ///
  (rcap ub2yearstakers lb2yearstakers timed if timed>-5 & timed<5, lcolor(cranberry) lwidth(medthick)) ///
    , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.8 (.4) .8) ///
  xlabel(-4 (1) 4) xtitle("") legend(label(1 "2 years Posting") ring(0) pos(11) cols(1) order(1)) ///
    xline(-0.5, lcolor(red)) xline(1.5, lcolor(red))
   graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logEBT_2y.png", replace
  
     twoway ///
   (connected betafulltakers timed if timed>-5 & timed<5, mcolor(blue) lcolor(blue) ) ///
  (rcap ubfulltakers lbfulltakers timed if timed>-5 & timed<5, lcolor(blue) lpattern(dash) lwidth(medthick)) ///
    , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.8 (.4) .8) ///
  xlabel(-4 (1) 4) xtitle("") legend(label(1 "Full Period Posting") ring(0) pos(11) cols(1) order(1)) ///
  xline(-0.5, lcolor(red))
   graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logEBT_full.png", replace
   
   
   *********************************************************
  
  
   use "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logemp_baseline_c1.dta", clear
   foreach  x in baseline fulltakers 2yearstakers 3yearstakers{
   merge 1:1 timed using "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logemp_`x'_c1.dta"
   drop _m
  }
  keep if timed>-6
  
  
  twoway (connected beta2yearstakers timed if timed>-5 & timed<5, mcolor(cranberry) lcolor(cranberry) ) ///
  (rcap ub2yearstakers lb2yearstakers timed if timed>-5 & timed<5, lcolor(cranberry) lwidth(medthick)) ///
   (connected beta3yearstakers timed if timed>-5 & timed<5, mcolor(black) lcolor(black) ) ///
  (rcap ub3yearstakers lb3yearstakers timed if timed>-5 & timed<5, lcolor(black) lpattern(dash) lwidth(medthick)) ///
   (connected betafulltakers timed if timed>-5 & timed<5, mcolor(blue) lcolor(blue)) ///
  (rcap ubfulltakers lbfulltakers timed if timed>-5 & timed<5, lcolor(blue) lpattern(dash) lwidth(medthick)) ///
  , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.4) .8) ///
  xlabel(-4 (1) 4) xtitle("") ///
  legend(label(1 "2 years Posting") label(3 "3 years Posting") label(5 "Full period Posting") cols(1) ring(0) pos(11) order(5 3 1)) ///
  xline(-0.5, lcolor(red)) 
  graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logemp_combined.png", replace
  
    twoway ///
   (connected beta3yearstakers timed if timed>-5 & timed<5, mcolor(black) lcolor(black) ) ///
  (rcap ub3yearstakers lb3yearstakers timed if timed>-5 & timed<5, lcolor(black) lpattern(dash) lwidth(medthick)) ///
    , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.4) .8) ///
  xlabel(-4 (1) 4) xtitle("") legend(label(1 "3 years Posting") ring(0) pos(11) cols(1) order(1)) ///
  xline(-0.5, lcolor(red)) xline(2.5, lcolor(red))
   graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logemp_3y.png", replace

      twoway ///
   (connected beta2yearstakers timed if timed>-5 & timed<5, mcolor(cranberry) lcolor(cranberry) ) ///
  (rcap ub2yearstakers lb2yearstakers timed if timed>-5 & timed<5, lcolor(cranberry) lwidth(medthick)) ///
    , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.4) .8) ///
  xlabel(-4 (1) 4) xtitle("") legend(label(1 "2 years Posting") ring(0) pos(11) cols(1) order(1)) ///
    xline(-0.5, lcolor(red)) xline(1.5, lcolor(red))
   graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logemp_2y.png", replace
  
     twoway ///
   (connected betafulltakers timed if timed>-5 & timed<5, mcolor(blue) lcolor(blue) ) ///
  (rcap ubfulltakers lbfulltakers timed if timed>-5 & timed<5, lcolor(blue) lpattern(dash) lwidth(medthick)) ///
    , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.4) .8) ///
  xlabel(-4 (1) 4) xtitle("") legend(label(1 "Full Period Posting") ring(0) pos(11) cols(1) order(1)) ///
  xline(-0.5, lcolor(red))
   graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logemp_full.png", replace
   
  


   use "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logca_baseline_c1.dta", clear
   foreach  x in baseline fulltakers 2yearstakers 3yearstakers{
   merge 1:1 timed using "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logca_`x'_c1.dta"
   drop _m
   }
   keep if timed>-6
  
  
  twoway (connected beta2yearstakers timed if timed>-5 & timed<5, mcolor(cranberry) lcolor(cranberry) ) ///
  (rcap ub2yearstakers lb2yearstakers timed if timed>-5 & timed<5, lcolor(cranberry) lwidth(medthick)) ///
   (connected beta3yearstakers timed if timed>-5 & timed<5, mcolor(black) lcolor(black) ) ///
  (rcap ub3yearstakers lb3yearstakers timed if timed>-5 & timed<5, lcolor(black) lpattern(dash) lwidth(medthick)) ///
   (connected betafulltakers timed if timed>-5 & timed<5, mcolor(blue) lcolor(blue)) ///
  (rcap ubfulltakers lbfulltakers timed if timed>-5 & timed<5, lcolor(blue) lpattern(dash) lwidth(medthick)) ///
  , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.4) .8) ///
  xlabel(-4 (1) 4) xtitle("") ///
  legend(label(1 "2 years Posting") label(3 "3 years Posting") label(5 "Full period Posting") cols(1) ring(0) pos(11) order(5 3 1)) ///
  xline(-0.5, lcolor(red)) 
  graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logca_combined.png", replace
  
   use "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logwagebill_baseline_c1.dta", clear
   foreach  x in baseline fulltakers 2yearstakers 3yearstakers{
   merge 1:1 timed using "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logwagebill_`x'_c1.dta"
   drop _m
  }
  keep if timed>-6
  
  
  twoway (connected beta2yearstakers timed if timed>-5 & timed<5, mcolor(cranberry) lcolor(cranberry) ) ///
  (rcap ub2yearstakers lb2yearstakers timed if timed>-5 & timed<5, lcolor(cranberry) lwidth(medthick)) ///
   (connected beta3yearstakers timed if timed>-5 & timed<5, mcolor(black) lcolor(black) ) ///
  (rcap ub3yearstakers lb3yearstakers timed if timed>-5 & timed<5, lcolor(black) lpattern(dash) lwidth(medthick)) ///
   (connected betafulltakers timed if timed>-5 & timed<5, mcolor(blue) lcolor(blue)) ///
  (rcap ubfulltakers lbfulltakers timed if timed>-5 & timed<5, lcolor(blue) lpattern(dash) lwidth(medthick)) ///
  , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.4) .8) ///
  xlabel(-4 (1) 4) xtitle("") ///
  legend(label(1 "2 years Posting") label(3 "3 years Posting") label(5 "Full period Posting") cols(1) ring(0) pos(11) order(5 3 1)) ///
  xline(-0.5, lcolor(red)) 
  graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logwagebill_combined.png", replace
  
  
  use "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logassets_baseline_c1.dta", clear
   foreach  x in baseline fulltakers 2yearstakers 3yearstakers{
   merge 1:1 timed using "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logassets_`x'_c1.dta"
   drop _m
  }
  keep if timed>-6
  
  
  twoway (connected beta2yearstakers timed if timed>-5 & timed<5, mcolor(cranberry) lcolor(cranberry) ) ///
  (rcap ub2yearstakers lb2yearstakers timed if timed>-5 & timed<5, lcolor(cranberry) lwidth(medthick)) ///
   (connected beta3yearstakers timed if timed>-5 & timed<5, mcolor(black) lcolor(black) ) ///
  (rcap ub3yearstakers lb3yearstakers timed if timed>-5 & timed<5, lcolor(black) lpattern(dash) lwidth(medthick)) ///
   (connected betafulltakers timed if timed>-5 & timed<5, mcolor(blue) lcolor(blue)) ///
  (rcap ubfulltakers lbfulltakers timed if timed>-5 & timed<5, lcolor(blue) lpattern(dash) lwidth(medthick)) ///
  , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.4) .8) ///
  xlabel(-4 (1) 4) xtitle("") ///
  legend(label(1 "2 years Posting") label(3 "3 years Posting") label(5 "Full period Posting") cols(1) ring(0) pos(11) order(5 3 1)) ///
  xline(-0.5, lcolor(red)) 
  graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logassets_combined.png", replace

  use "$outputs/ES/Baseline_Export5/Hetero1/Estimates/loghours_baseline_c1.dta", clear
   foreach  x in baseline fulltakers 2yearstakers 3yearstakers{
   merge 1:1 timed using "$outputs/ES/Baseline_Export5/Hetero1/Estimates/loghours_`x'_c1.dta"
   drop _m
  }
  keep if timed>-6
  
  
  twoway (connected beta2yearstakers timed if timed>-5 & timed<5, mcolor(cranberry) lcolor(cranberry) ) ///
  (rcap ub2yearstakers lb2yearstakers timed if timed>-5 & timed<5, lcolor(cranberry) lwidth(medthick)) ///
   (connected beta3yearstakers timed if timed>-5 & timed<5, mcolor(black) lcolor(black) ) ///
  (rcap ub3yearstakers lb3yearstakers timed if timed>-5 & timed<5, lcolor(black) lpattern(dash) lwidth(medthick)) ///
   (connected betafulltakers timed if timed>-5 & timed<5, mcolor(blue) lcolor(blue)) ///
  (rcap ubfulltakers lbfulltakers timed if timed>-5 & timed<5, lcolor(blue) lpattern(dash) lwidth(medthick)) ///
  , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.4) .8) ///
  xlabel(-4 (1) 4) xtitle("") ///
  legend(label(1 "2 years Posting") label(3 "3 years Posting") label(5 "Full period Posting") cols(1) ring(0) pos(11) order(5 3 1)) ///
  xline(-0.5, lcolor(red)) 
  graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/loghours_combined.png", replace

   use "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logcash_baseline_c1.dta", clear
   foreach  x in baseline fulltakers 2yearstakers 3yearstakers{
   merge 1:1 timed using "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logcash_`x'_c1.dta"
   drop _m
  }
  keep if timed>-6
  
  
  twoway (connected beta2yearstakers timed if timed>-5 & timed<5, mcolor(cranberry) lcolor(cranberry) ) ///
  (rcap ub2yearstakers lb2yearstakers timed if timed>-5 & timed<5, lcolor(cranberry) lwidth(medthick)) ///
   (connected beta3yearstakers timed if timed>-5 & timed<5, mcolor(black) lcolor(black) ) ///
  (rcap ub3yearstakers lb3yearstakers timed if timed>-5 & timed<5, lcolor(black) lpattern(dash) lwidth(medthick)) ///
   (connected betafulltakers timed if timed>-5 & timed<5, mcolor(blue) lcolor(blue)) ///
  (rcap ubfulltakers lbfulltakers timed if timed>-5 & timed<5, lcolor(blue) lpattern(dash) lwidth(medthick)) ///
  , graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(gs10) lpattern(dash)) ylabel(-.2 (.4) .8) ///
  xlabel(-4 (1) 4) xtitle("") ///
  legend(label(1 "2 years Posting") label(3 "3 years Posting") label(5 "Full period Posting") cols(1) ring(0) pos(11) order(5 3 1)) ///
  xline(-0.5, lcolor(red)) 
  graph export "$outputs/ES/Baseline_Export5/Hetero1/Estimates/logcash_combined.png", replace
  
